#include "citycode.h"


cityCode::cityCode()
    :DMainWindow()
{

}

QString cityCode::getCityCode(QString city)
{
    // 使用QFile打开文件
    QFile file(filePath);
    if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) {
        qDebug() << "Cannot open file for reading:" << filePath;
        return "";

    }
    // 读取文件内容到QByteArray
    fileContent = file.readAll();
    file.close();

    // 解析JSON
    jsonDoc = QJsonDocument::fromJson(fileContent);
    if (jsonDoc.isNull()) {
        qDebug() << "Error parsing JSON";
        return "";
    }

    return jsonDoc.object().value(city).toString();
}
